<template>
    <h1>EL-表单组件</h1>
    <el-form style="width:500px; margin:0 auto;" label-width="80px">
        <el-form-item label="用户名">
            <el-input v-model="xx.username" placeholder="请输入用户名" ></el-input>
        </el-form-item>
        <br>
        <el-form-item label="密码">
            <el-input v-model="xx.password" placeholder="请输入密码" show-password></el-input>
        </el-form-item>
        <br>
        <el-form-item label="性别">
        <el-radio-group v-model="xx.sex" label="性别">
            <el-radio-button label="♂">男</el-radio-button>
            <el-radio-button label="♀">女</el-radio-button>
        </el-radio-group>
        </el-form-item>
        <br>
        <el-form-item label="城市">
        
        <el-select v-model="xx.city" placeholder="请选择城市" style="width: 50%;">
            <el-option label="太原" value="太原"></el-option>
            <el-option label="上海" value="上海"></el-option>
            <el-option label="西安" value="西安"></el-option>
            <el-option label="巴黎" value="巴黎"></el-option>
            <el-option label="重庆" value="重庆"></el-option>
            <el-option label="北京" value="北京"></el-option>
            <el-option label="成都" value="成都"></el-option>
            <el-option label="武汉" value="武汉"></el-option>
            <el-option label="广州" value="广州"></el-option>
            <el-option label="深圳" value="深圳"></el-option>
            <el-option label="昆明" value="昆明"></el-option>
            <el-option label="杭州" value="杭州"></el-option>
            <el-option label="南京" value="南京"></el-option>
            <el-option label="天津" value="天津"></el-option>
            <el-option label="郑州" value="郑州"></el-option>
            <el-option label="青岛" value="青岛"></el-option>
            <el-option label="厦门" value="厦门"></el-option>
            <el-option label="长沙" value="长沙"></el-option>
            <el-option label="合肥" value="合肥"></el-option>
            <el-option label="福州" value="福州"></el-option>
            <el-option label="南昌" value="南昌"></el-option>
            <el-option label="济南" value="济南"></el-option>
            <el-option label="沈阳" value="沈阳"></el-option>
            <el-option label="长春" value="长春"></el-option>
            <el-option label="哈尔滨" value="哈尔滨"></el-option>
            <el-option label="石家庄" value="石家庄"></el-option>
        </el-select>
        </el-form-item>
        <br>
        <el-form-item label="管理员">
        <el-switch v-model="xx.num" :active-value="1" :inactive-value="0"></el-switch>
        </el-form-item>
        <br>
        <el-button type="primary" @click="login">点我提交</el-button>
    </el-form>
    
</template>

<script setup>
import {ref} from "vue";

const xx = ref({
    username: "",
    password: "",
    sex: "",
    city: "",
    num: 0
});
// 提交用户数据
const login = () => {
    console.log(xx.value);
    xx.value = {
        username: "",
        password: "",
        sex: "",
        city: "",
        num: 0
    };
};
</script>

<style scoped>

</style>